Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(auto-configuration-web): add configuration helper functions for web #2418

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

martinkuba
Copy link
Contributor

Addresses open-telemetry/opentelemetry-js#4702
Alternative to open-telemetry/opentelemetry-js#4325

This is an alternative to creating a Web SDK package (similar to Node SDK). Instead of having an SDK class, this PR introduces helper functions for configuring different parts of web instrumentation.

Copy link

codecov bot commented Sep 3, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 90.38%. Comparing base (dfb2dff) to head (280153e).
Report is 226 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2418      +/-   ##
==========================================
- Coverage   90.97%   90.38%   -0.60%     
==========================================
  Files         146      151       +5     
  Lines        7492     7302     -190     
  Branches     1502     1531      +29     
==========================================
- Hits         6816     6600     -216     
- Misses        676      702      +26     

see 78 files with indirect coverage changes

Copy link
Member

@pichlermarc pichlermarc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@martinkuba overall structure looks promising 🙂 I do have a few questions I have around allowing multiple ways to set the same thing and the complexity that entails. 🤔 Having occasionally worked on NodeSDK, I've seen this get out of control quite quickly. Therefore I'd recommend doing an iterative approach (starting out with very few duplicate configurations, then adding more where necessary to make it simpler for the user). This can make maintenance easier going forward (and possibly also reduce user-confusion).

Another note: before we can continue we'll need to find owners that will be assigned to this package and will maintain it going forward.

metapackages/auto-configuration-web/karma.conf.js Outdated Show resolved Hide resolved
}

export function configureWebSDK(
config: TraceSDKConfiguration & EventSDKConfiguration,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could we do

Suggested change
config: TraceSDKConfiguration & EventSDKConfiguration,
config: {config: { traces: TraceSDKConfiguration, events: EventSDKConfiguration },

It makes resource be the odd-one out though as right now it's shared across both, but this would require the user to set both. 🤔

* limitations under the License.
*/

export * from './utils';
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We've been gradually switching to explicit exports over all packages to avoid that we unintentionally add to the public API, I think we should also use explicit exports here.

Comment on lines +68 to +69
logRecordProcessors?: LogRecordProcessor[];
logRecordExporter?: LogRecordExporter;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if we should allow either processors or exporters here, but not both 🤔
In general, I think the more we can reduce special cases where we need to auto-pair things/merge configs with other configs the better.

Comment on lines +134 to +137
if (!tracerConfig.resource && config.resource) {
tracerConfig.resource = config.resource;
}
const tracerProvider = new WebTracerProvider(tracerConfig);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, does it make it simpler for a user to have two places to specify the resource? 🤔
I wonder if we could be simplified to just take the resource from the tracerConfig if present without having too much impact on usability.

};
}

export function getResource(config?: ResourceConfiguration): Resource {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's a specification on resource merging that states that when there's a resource provided, we may not auto-merge service.* into it even if it's not present. We should ensure that we align with that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants